<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>继承</title>
</head>
<body>

  <script>
    // 1.原型链继承
    // 2.构造函数继承
    // 3.组合继承 = 1 + 2
    // 4.寄生式继承
    function Person(name) {
      this.name = name
    }
    
    Person.prototype.getName = function() {
      return this.name
    }

    // 子类
    function Child(name) {
      Person.call(this, name)
    }
    Child.prototype = Object.create(Person.prototype)
    Child.prototype.constructor = Child
    
    let child = new Child("夏天")
    console.log(child.getName())


  </script>
</body>
</html>